package com.richpencil.config.datasource;


import com.querydsl.jpa.impl.JPAQueryFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.persistence.EntityManager;

@Service
public class BaseService {
    @Autowired
    @Qualifier("entityManagerPrimary")
    EntityManager  entityManagerPrimary;

    protected JPAQueryFactory jpaQueryFactory;

    protected JPAQueryFactory jpaQueryFactoryK3;

    protected JPAQueryFactory jpaQueryFactoryFL;

    /*
    @Autowired
    @Qualifier("entityManagerK3")
    EntityManager  entityManagerK3;

    @Autowired
    @Qualifier("entityManagerFL")
    EntityManager  entityManagerFL;*/

    @PostConstruct
    public void init(){
        this.jpaQueryFactory=new JPAQueryFactory(this.entityManagerPrimary);
        //this.jpaQueryFactoryK3=new JPAQueryFactory(this.entityManagerK3);
        //this.jpaQueryFactoryFL=new JPAQueryFactory(this.entityManagerFL);
    }
}
